package org.knot.autojmx.metadata;

import java.lang.reflect.Field;


/**
 * 
 * @author <a href="mailto:yuxiaoweimail@gmail.com">yuxiaowei</a>
 *
 */
public class PropertyField {

    private String m_name;
    
    private String m_rights;
     
    private String m_type;
     
    private Field m_field;
     
    private boolean m_notification;
    
    private String description;

    
    public void setDescription(String description) {
		this.description = description;
	}


	public PropertyField(String name, Field field, String rights, String type) {
        this.setName(name);
        this.setField(field);
        this.m_type = type;
        this.setRights(rights);
    }

    
    public Field getField() {
        return m_field;
    }

   
    public void setField(Field field) {
        this.m_field = field;
    }

    
    public String getName() {
        return m_name;
    }

     
    public void setName(String name) {
        this.m_name = name;
    }

     
    public String getRights() {
        return m_rights;
    }

    
    public void setRights(String rights) {
        this.m_rights = rights;
    }

     
    public String getType() {
        return this.m_type;
    }


    public boolean isReadable() {
        return this.getRights().equals("r") || this.getRights().equals("w");
    }

    public boolean isWritable() {
        return this.getRights().equals("w");
    }

    public boolean isNotifiable() {
        return this.m_notification;
    }

   
    public void setNotifiable(boolean value) {
        this.m_notification = value;
    }

    public static boolean isRightsValid(String rights) {
        return rights != null && (rights.equals("r") || rights.equals("w"));
    }

	public String getDescription() {
		return description;
	}

}
